<?php

namespace Shuai\Phpwx;

use Encore\Admin\Admin;
use Illuminate\Support\ServiceProvider;

class PhpwxServiceProvider extends ServiceProvider
{
    /**
     * {@inheritdoc}
     */
    public function boot(Phpwx $extension)
    {
        if (! Phpwx::boot()) {
            return ;
        }

        if ($views = $extension->views()) {
            $this->loadViewsFrom($views, 'phpwx');
        }

        if ($this->app->runningInConsole() && $assets = $extension->assets()) {
            $this->publishes(
                [$assets => public_path('vendor/shuai/phpwx')],
                'phpwx'
            );
        }

        $this->app->booted(function () {
            Phpwx::routes(__DIR__.'/../routes/web.php');
        });

        Admin::css('vendor/shuai/phpwx/foo.css');
    }
}
